<template>
      
    <div class="fronthome-box">
<!--  头部  -->
      <div :class="topclass" class="jp_tabsBox">
        <div style="width: 200px; text-align: center" @click="outHome">
          <img src="@/assets/backlogo.png" style="height: 80px;" >
        </div>
        <div  class="buhuanhang" style="flex: 1;height: 60px;background-color:rgba(240,240,240,0);">
          <el-menu :default-active="'1'" class="el-menu-demo" mode="horizontal" style="background-color:rgba(240,240,240,0);height: 60px;border: none;display: flex;flex-wrap: nowrap;" router>
            <el-menu-item index="/front/shouye" style="background-color:rgba(240,240,240,0);border: none" class="daohang " ref="sy"><span @mouseover="hovervibration($refs.sy)" @mouseout="hovervibrationOut($refs.sy)">首页</span></el-menu-item>
            <el-menu-item index="/front/home" style="background-color:rgba(240,240,240,0);border: none" class="daohang" ref="sc"><span @mouseover="hovervibration($refs.sc)" @mouseout="hovervibrationOut($refs.sc)">商城</span></el-menu-item>
            <el-menu-item index="/front/kecheng" style="background-color:rgba(240,240,240,0);border: none" class="daohang" ref="kc"><span @mouseover="hovervibration($refs.kc)" @mouseout="hovervibrationOut($refs.kc)">课程</span></el-menu-item>
            <el-menu-item  style="background-color:rgba(240,240,240,0);border: none" @click="blankBoke" class="daohang" ref="bkzx"><span @mouseover="hovervibration($refs.bkzx)" @mouseout="hovervibrationOut($refs.bkzx)">博客中心</span></el-menu-item>
            <el-menu-item index="/front/vip" style="background-color:rgba(240,240,240,0);border: none" class="daohang" ref="hyg"><span @mouseover="hovervibration($refs.hyg)" @mouseout="hovervibrationOut($refs.hyg)">会员购</span></el-menu-item>
            <el-menu-item index="/front/Chonzhi" style="background-color:rgba(240,240,240,0);border: none" class="daohang" ref="cz"><span @mouseover="hovervibration($refs.cz)" @mouseout="hovervibrationOut($refs.cz)">充值</span></el-menu-item>
          </el-menu>
        </div>


        <div class="sty-span" style="height: 50px;margin-right: 50px;background-color:rgba(240,240,240,0);">
          <el-menu :default-active="'1'" class="el-menu-demo" mode="horizontal" style="background-color:rgba(240,240,240,0);border: none;padding: 5px;padding-right: 20px;padding-top: 10px;display: flex;flex-wrap: nowrap;" router>
            <el-menu-item index="/front/ShoppingTrolley"
                          style=" background-color:rgba(240,240,240,0);position: relative;border: none; " class="daohang danghangyou">
              <el-badge class="mark"  style="position: absolute;right: 0; top: 0; display: flex;border: none;"  :value="$store.state.shoppingNum" />
              <span style="">购物车</span>
              <img src="../../assets/goods.png" style="width: 30%;" alt="" srcset="">
            </el-menu-item>

          </el-menu>
        </div>
        <!-- 头像  -->
        <div class="touxiang" style="width: 100px; background-color:rgba(240,240,240,0);margin-right: 100px;margin-top: 8px;display:flex;justify-content: center;align-items: center;">
          <div v-if="!user.username" style="opacity: 1;width: 150px;">
              <div style="height: 100%; display:flex;justify-content: center;align-items: center;" class="" @mouseenter="inUser" @mouseleave="outUser">
                <el-dropdown  class="showUser">
                  <el-dropdown-menu></el-dropdown-menu>
                  <div class="userimg">
                    <div class="userimg_tu inline_block dengluimg">
                      <span style="font-weight: 800;font-size: 20px;color: white;">登录</span>
                      <div @mouseenter="inshow" @mouseleave="outshow" v-show="showUser" class="caidan" style="height: 100px; width: 180px;left:-65px;">
                          <el-button style="width: 100px;background-color: #00aeec;border: none;border-radius: 10px;">
                            <router-link to="/NewLogin" style="text-decoration: none;color: white;font-size: 15px;font-weight: 800;">立即登录</router-link>
                          </el-button>
                          <div style="text-align: center;line-height: 30px;font-size: 15px;font-weight: 400;">
                            首次使用？
                            <router-link to="/NewLogin" style="text-decoration: none;color: #00b5e5;">点我注册</router-link>
                          </div>
                      </div>
                    </div>
                  </div>
                </el-dropdown>
              </div>
          </div>
          <div v-else>
            <div style="display:flex; font-size: 12px" class="" @mouseenter="inUser" @mouseleave="outUser">
              <el-dropdown  class="showUser">
                <el-dropdown-menu></el-dropdown-menu>
                <div class="userimg">
                  <div class="userimg_tu2 inline_block">
                    <img class="img2" :src="user.avatarUrl" alt="">
                    <transition name="el-fade-in-linear">
                      <div v-show="showUser" class="caidan2"  @mouseenter="inshow" @mouseleave="outshow" >
                        <div style="height: 50px;width: 100%;"></div>
                        <div style="width:100%;height: 50px;text-align: center;line-height: 50px;"><h2 style=" font-size: 30px;font-weight: 800">{{user.nickname}}</h2></div>
                        <div style="width:100%;color: #9499a0;">
                          <div class="inline_block pingjun bianse">文章</div>
                          <div class="inline_block pingjun bianse">说说</div>
                          <div class="inline_block pingjun bianse">关注</div>
                          <div class="inline_block pingjun bianse">粉丝</div>
                        </div>
                        <div class="genr" @click="$router.push('/front/user')">
                          <span style="float: left;">个人中心</span>
                          <span style="float: right;font-weight: 100;">普通用户</span>
                        </div>
                        <div class="genr" >
                          <span style="float: left;">金币</span>
                          <span style="float: right;font-weight: 100;">0 <span>币</span></span>
                        </div>
                        <div class="genr" >
                          <span style="float: left;">订购会员</span>
                        </div>
                        <div class="genr" >
                          <span style="float: left;">我的购买</span>
                        </div>
                        <div class="genr">
                          <span class="genren" style="text-decoration: none" @click="logOut">退出</span>
                        </div>
                      </div>
                    </transition>
                  </div>
                </div>
              </el-dropdown>
            </div>
          </div>
        </div>


      </div>
      <div style="margin-top: 0px;">
        <router-view @refreshUser="getUser"/>
      </div>
      <cbNav :routerClass="routerClass"></cbNav>
      <!-- <bottomNavVue></bottomNavVue> -->
    </div>

</template>

<script>
import { log } from 'three';
import {serverIp} from '../../../public/config';
import cbNav from '@/components/CeBianNav/cbNav.vue';
// import bottomNavVue from '@/components/bottom-nav.vue';

export default {
  name: "FrontHome",
  components:{
    cbNav,
    // bottomNavVue
  },
  data(){
    return{
      serverIp: serverIp,
      user:localStorage.getItem("user") ? JSON.parse(localStorage.getItem("user")):{},
      showUser: false,
      pathvalue:'',
      topclass: 'fronthome',
      showdenglu: false,
      bbn:false,
      routerClass: "bounceIn animated"
    }
  },
  methods:{
    blankBoke(){
      let routeUrl = this.$router.resolve({
        path: "/",
      });
      window.open(routeUrl.href, '_blank');
    },
    openShopping(){
      let routeUrl = this.$router.resolve({
        path: "/front/shoppingTrolley",
      });
      window.open(routeUrl.href, '_blank');
    },
    logOut(){
      // console.log(this)
      this.$store.commit("logoutOn")
      this.$message.info("退出成功")
    },
    getUser(){
      this.request.get("/user/"+this.user.id).then(res=>{
        // console.log("Manage"+res.data)
        this.user = res.data
      })
    },
    outHome(){
      this.$router.push('/front/home')
    },
    //鼠标悬停头像
    inUser(){
      this.showUser =true;
      // console.log(this.showUser);
    },
    //鼠标移出
    outUser(){
      this.sleep(400);
      if(!this.bbn){
        this.showUser =false;
      }
      // console.log(this.showUser);
    },
    sleep(ms) { //sleep延迟方法
      var unixtime_ms = new Date().getTime();
      while(new Date().getTime() < unixtime_ms + ms) {}
    },
    inshow(){
      // console.log('jin');
      this.bbn =true;
      // console.log(this.showUser);
    },
    outshow(){
      // console.log('chu');
      this.bbn=false;
      // console.log(this.showUser);
    },
    //鼠标滑过震动
    hovervibration(refvalue){
      refvalue.$el.className = "el-menu-item daohang wobble animated";
    },
    hovervibrationOut(refvalue){
      refvalue.$el.className = "el-menu-item daohang";
    }
  },
  watch:{
      'pathvalue':{
        handler(value){
          this.routerClass = ''
          if(value === "/front/shouye"){
            this.topclass = 'fronthomeHome';
          }else if(value === "/front/user"){
            this.topclass = 'fronthomeHome2';
          }else{
            this.topclass = 'fronthome';
          }
          setTimeout(() => {
            this.routerClass = "bounceIn animated"
          }, 10);
          
        }
      }
  },
  created(){
    this.pathvalue = this.$route.path;
  },
  updated(){
    // console.log("updata",this.$route.path);
    this.pathvalue = this.$route.path
  }
}
</script>

<style scoped lang="less">

// .sty-span{
//   span{
//     font-family: hunsize;
//   }
// }
.item {
  height: 50px;
  float: right;
  top: 10px;
  position: relative;
  margin-right: 60px;
}
/*.item::after{*/
/*  content: '';*/
/*  !* after默认是行内元素，需要修改为块元素 *!*/
/*  display: block;*/
/*  clear: both;*/
/*}*/

.gwcbut{
  font-size: 15px;
  float: right;
  padding-right: 5px;
  overflow: hidden;
  // display: block;
  // display:none;
}

// sup{
//   margin-top: 10px;
// }
.fronthome-box{

  position: relative;
  z-index: 1;
  background-color: #efefef;
  /*背景色*/
  background-image: linear-gradient(90deg, rgba(150, 150, 150, 0.15) 10%, rgba(134, 134, 134, 0) 10%), linear-gradient(0deg, rgba(151, 151, 151, 0.15) 10%, rgba(0, 0, 0, 0) 10%);
  /*rgba(0, 0, 0, 0)，transparent全透明黑*/
  background-size: 18px 18px;
  .fronthome{
    box-shadow: rgba(100, 100, 111, 0.3) 0px 7px 29px 0px !important;
    display: flex;
    width: 100%; 
    height: 90px; 
    border-bottom: 1px solid #e6e6e6;
    background-color: #ffffff;
  //   position: absolute;
    // background-image: url(../../assets/zhuyebg1.jpg);
  }
  .fronthomeHome{
    display: flex;
    width: 100%; 
    height: 80px;
    position: absolute;
    border: none;
  }
  .fronthomeHome2{
    display: flex;
    width: 100%; 
    height: 80px;
    position: absolute;
    background-color: white;
    border: none;

  }
}

/*头像*/
.touxiang{
  display: flex;
  justify-content: center;
  align-items: center;
  .showUser{
    width: 60px;
    height: 60px;
    cursor: pointer;
    .userimg {
      display: inline-block;
      width: 60px;
      height: 60px;
      position: relative;
      .userimg_tu2 {
        width: 70px;
        height: 70px;
        display: flex;
        justify-content: center;
        align-items: center;
        .img2{
          background-size: contain;
          width: 70px;
          height: 70px;
          border-radius: 50%;
          border: 4px solid white;
          top: -10px;
          position: relative;
          z-index: 2153;
          transition-property: width height;
          transition-duration: 0.2s;
        }

        .caidan2{
          position:absolute;
          width: 250px;
          height: 370px;
          top: 100px;
          opacity: 0;
          left: -85px;
          z-index: 2000;
          border-radius: 10px;
          background-color: white ;
          box-shadow:5px 5px 15px #999;
          transition-duration: 0.2s;
          transition-delay: 0.1s;
        }
      }
      .userimg_tu2:hover .img2{
        margin-top: 100px;
        width: 120px;
        height: 120px;
      }
      .userimg_tu2:hover .caidan2{
        top: 100px;
        opacity: 1;
      }
    }
  }
  .inline_block{
    display: inline-block;
  }
  .pingjun{
    width:62.5px;
    height: 40px;
    font-size: 18px;
    text-align: center;
  }
  .bianse:hover{
    color: #00aeec;
  }
  .genr{
    margin: 0 auto;
    margin-top: 3px;
    padding: 0 10px 0 10px;
    width: 90%;
    height: 40px;
    line-height: 40px;
    border-radius: 8px;
    text-align: center;
    font-size: 15px;
    font-weight: 900;
    .genren{
      color: #61666D;
    }
  }
  .genr:hover{
    background-color: #E3E5E7;
  }
  .userimg_tu {
    width: 50px;
    height: 50px;
    padding-bottom: 20px;
    .caidan{
      position: absolute;
      left: -65px;
      top: 50px;
      height: 100px;
      width: 180px;
      padding: 10px;
      opacity: 0;
      z-index: 2000;
      border-radius: 5px;
      background-color: white ;
      font-size: 10px;
      transition-duration: 0.5s;
      transition-delay: 0.2s;
    }
  }
  .userimg_tu:hover{
    padding-bottom: 20px !important;
  }
  .userimg_tu:hover .caidan{
    opacity: 1;
  }
  .dengluimg{
    width: 50px !important;
    height: 50px !important;
    line-height: 50px;
    background-color: #7dbafe;
    border: 1px solid #7dbafe;
    border-radius: 50%;
    background-size: 50px; 
    text-align: center;
    position: relative;
    cursor: pointer;
    transition-duration: 3s;

  }
}

/deep/ .daohang{
  font-size: 20px !important;
  height: 90px;
  line-height: 90px;
  border: none;
}
.danghangyou{
  position: relative;
  img{
    width: 20px;
    position: absolute;left: 35%;top: 10%;
  }
  span{
    position: relative;
    top: 5%;
  }
}
.tougao{
  height: 50px;
  line-height: 50px;
  padding: 0;
  border-radius: 5px;
  padding: 0 20px 0 20px;
  background-color:#7dbafe !important;
  .bubian{
    position: none;
    height: 15px;
    margin-right: 5px;
  }
}

.buhuanhang{
  width: 400px !important;
  // span{
  //   font-family: hunsize;
  // }
}
// @font-face {
//   font-family: hunsize;
//   src: url(../../assets/size/字小魂梦幻体\(商用需授权\).ttf);
// }

/*base code*/
.animated {
  -webkit-animation-duration: 0.7s;
  animation-duration: 0.8s;
  -webkit-animation-fill-mode: both;
  animation-fill-mode: both;
}
.animated.infinite {
  -webkit-animation-iteration-count: infinite;
  animation-iteration-count: infinite;
}
.animated.hinge {
  -webkit-animation-duration: 2s;
  animation-duration: 2s;
}
/*the animation definition*/
@-webkit-keyframes wobble {
  0% {
    -webkit-transform: none;
    transform: none
  }
  15% {
    -webkit-transform: translate3d(-25%, 0, 0) rotate3d(0, 0, 1, -5deg);
    transform: translate3d(-25%, 0, 0) rotate3d(0, 0, 1, -5deg)
  }
  30% {
    -webkit-transform: translate3d(20%, 0, 0) rotate3d(0, 0, 1, 3deg);
    transform: translate3d(20%, 0, 0) rotate3d(0, 0, 1, 3deg)
  }
  45% {
    -webkit-transform: translate3d(-15%, 0, 0) rotate3d(0, 0, 1, -3deg);
    transform: translate3d(-15%, 0, 0) rotate3d(0, 0, 1, -3deg)
  }
  60% {
    -webkit-transform: translate3d(10%, 0, 0) rotate3d(0, 0, 1, 2deg);
    transform: translate3d(10%, 0, 0) rotate3d(0, 0, 1, 2deg)
  }
  75% {
    -webkit-transform: translate3d(-5%, 0, 0) rotate3d(0, 0, 1, -1deg);
    transform: translate3d(-5%, 0, 0) rotate3d(0, 0, 1, -1deg)
  }
  100% {
    -webkit-transform: none;
    transform: none
  }
}
@keyframes wobble {
  0% {
    -webkit-transform: none;
    -ms-transform: none;
    transform: none
  }
  15% {
    -webkit-transform: translate3d(-25%, 0, 0) rotate3d(0, 0, 1, -5deg);
    -ms-transform: translate3d(-25%, 0, 0) rotate3d(0, 0, 1, -5deg);
    transform: translate3d(-25%, 0, 0) rotate3d(0, 0, 1, -5deg)
  }
  30% {
    -webkit-transform: translate3d(20%, 0, 0) rotate3d(0, 0, 1, 3deg);
    -ms-transform: translate3d(20%, 0, 0) rotate3d(0, 0, 1, 3deg);
    transform: translate3d(20%, 0, 0) rotate3d(0, 0, 1, 3deg)
  }
  45% {
    -webkit-transform: translate3d(-15%, 0, 0) rotate3d(0, 0, 1, -3deg);
    -ms-transform: translate3d(-15%, 0, 0) rotate3d(0, 0, 1, -3deg);
    transform: translate3d(-15%, 0, 0) rotate3d(0, 0, 1, -3deg)
  }
  60% {
    -webkit-transform: translate3d(10%, 0, 0) rotate3d(0, 0, 1, 2deg);
    -ms-transform: translate3d(10%, 0, 0) rotate3d(0, 0, 1, 2deg);
    transform: translate3d(10%, 0, 0) rotate3d(0, 0, 1, 2deg)
  }
  75% {
    -webkit-transform: translate3d(-5%, 0, 0) rotate3d(0, 0, 1, -1deg);
    -ms-transform: translate3d(-5%, 0, 0) rotate3d(0, 0, 1, -1deg);
    transform: translate3d(-5%, 0, 0) rotate3d(0, 0, 1, -1deg)
  }
  100% {
    -webkit-transform: none;
    -ms-transform: none;
    transform: none
  }
}
.wobble {
  -webkit-animation-name: wobble;
  animation-name: wobble
}




</style>